<!--  -->
<template>
  <div class="tab-control">
    <div
      class="control-item"
      v-for="(item, index) in list"
      :key="index"
      @click="switchClick(index)"
    >
      <p :class="{ active: index == currentIndex }">{{ item }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  props: {
    list: {
      type: Array,
      default() {
        return [];
      }
    },
    currentIndex: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {};
  },
  methods: {
    switchClick(index) {
      this.$emit("tabControlClick", index);
    }
  },
  components: {}
};
</script>

<style scoped>
.tab-control {
  padding: 8px;
  background: #fff;
  display: flex;
  justify-content: center;
  align-content: center;
}
.control-item {
  flex: auto;
  text-align: center;
}
.control-item p {
  display: inline-block;
  padding: 4px 8px;
}
.active {
  color: var(--color-tint);
  border-bottom: 3px solid var(--color-tint);
}
</style>
